import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-05-06
 * Time: 22:40
 */
public class TestDemo {
    //二维数组
    public static void main(String[] args) {
        int[][] arr1 = {{1,2,3},{4,5,6}};
//        int[][] arr2 = new int[2][3];
//        int[][] arr3 = new int[][]{{1,2,3},{4,5,6}};
        for (int i = 0; i < arr1.length; i++) {
            for (int j = 0; j < arr1[i].length; j++) {
                System.out.print(arr1[i][j]+" ");
            }
            System.out.println();
        }
    }
    //数组作为函数的返回值 获取斐波那契数列的前N项
    public static int[] fib(int n){
        if(n<=0){
            return null;
        }
        int[] arr = new int[n];
        arr[0]=1;
        arr[1]=1;
        if(n>2){
            for (int i = 3; i < n; i++) {
                arr[i] = arr[i-1]+arr[i-2];
            }
        }
        return arr;
    }
    public static void main5(String[] args) {
        int[] arr = fib(10);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
    }
    public static void fuc(int a){
        a = 20;
    }
    public static void main4(String[] args) {
        int a = 10;
        fuc(a);
        System.out.println(a);
    }
    public static void main3(String[] args) {
        int[] arr = {1,2,3,4,5};
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i]+" ");
        }
    }
    public static void main2(String[] args) {
        int[] arr = null;
        System.out.println("arr:"+arr);
        System.out.println(arr.length);
    }
    public static void func(int[] arr){
        arr[0]=100;
    }
    public static void main1(String[] args) {
        int[] arr = {1,2,3,4,5,6};
        func(arr);
        String ret = Arrays.toString(arr);
        System.out.println(ret);
        System.out.println("======for each=====");
        for (int x:arr) {
            System.out.print(x+" ");

        }
    }
}
